from drf_haystack.serializers import HaystackSerializer
from rest_framework import serializers

from apps.goods.models import SKU
from apps.goods.search_indexes import SKUIndex

class HotSkuListSerializer(serializers.ModelSerializer):
    class Meta:
        model = SKU
        fields = ('id',"name","price","default_image_url","comments")

#Haystack序列化器
class SKUIndexSerializer(HaystackSerializer):

    class Meta:
        #指定搜索index类
        index_classes = [SKUIndex]
        fields = ('text', 'id', 'name', 'price', 'default_image_url', 'comments')